import * as validator from './validator'

const createUsername = () => {
  return [
    {required: true, message: '账户名不能为空'},
    {min: 6, max: 16, message: '长度在 6 到 16 个字符'},
    {validator: validator.createUsername()}
  ];
};

const createAdminUsername = () => {
  return [
    {required: true, message: '账户名不能为空'},
    {min: 3, max: 16, message: '长度在 3 到 16 个字符'},
    {validator: validator.createAdminUsername()}
  ];
};

const createPassword = () => {
  return [
    {required: true, message: '密码不能为空'},
    {min: 8, max: 20, message: '长度在 8 到 20 个字符'}
  ];
};

const createPasswordMixType = () => {
  return [
    {required: true, message: '密码不能为空',},
    {pattern: /^(?!\d+$)(?![A-Z]+$)(?![a-z]+$)(?![`~!@#$%^&*()-=_+[]\{}|;:”,\.\/<>\?]+$)\S{8,20}$/, message: '密码长度在8到20个字符，至少包含“数字/字母/特殊字符”的2种组合'},
  ];
};
const createUri = () => {
  return [
    {validator: validator.createUri()}
  ];
};

const createActiveUri = () => {
  return [
    {validator: validator.createActiveUri()}
  ];
};

const createCardNumber = () => {
  return [
    {required: true, message: '银行卡卡号不能为空'},
    {validator: validator.createCardNumber()}
  ];
};

const createRate = () => {
  return [
    {required: true, message: '利率必须填写'},
    {type: 'number', message: '必须填写数字'},
    {type: 'number', min: 0, max: 100, message: '必须在0到100之间'}
  ];
};
const createPercent = () => {
  return [
    {required: true, message: '比例必须填写'},
    {type: 'number', message: '必须填写数字'},
    {type: 'number', min: 0, max: 100, message: '必须在0到100之间'}
  ];
};
const createPercent1000 = () => {
  return [
    {required: true, message: '比例必须填写'},
    {type: 'number', message: '必须填写数字'},
    {type: 'number', min: 0, max: 1000, message: '必须在0到1000之间'}
  ];
};
const createMoney = () => {
  return [
    {required: true, message: '金额必须填写'},
    {type: 'number', message: '必须填写数字'},
    {validator: validator.createNonNegativeInteger()}
  ];
};
const createFloatMoney = () => {
  return [
    {required: true, message: '金额必须填写'},
    {type: 'number', message: '必须填写数字'},
    {validator: validator.createNonNegativeNumber()}
  ];
};
const createTimes = () => {
  return [
    {required: true, message: '次数必须填写'},
    {type: 'number', message: '必须填写数字'},
    {validator: validator.createNonNegativeInteger()}
  ];
};
const createMoneyType = () => {
  return [
    {type: 'number', message: '必须填写数字'},
    {validator: validator.createNonNegativeInteger()}
  ];
};
const createMultipleType = () => {
  return [
    {required: true, message: '倍数必须填写'},
    {type: 'number', message: '必须填写数字'},
  ];
};

export {
  createUsername,
  createAdminUsername,
  createPassword,
  createPasswordMixType,
  createUri,
  createActiveUri,
  createCardNumber,
  createRate,
  createMoney,
  createFloatMoney,
  createMoneyType,
  createTimes,
  createPercent,
  createPercent1000,
  createMultipleType
}
